import { HttpClient } from '@angular/common/http';
import { Inject, Injectable } from '@angular/core';
import { API_CONFIG, ServiceModule } from './service.module';

@Injectable({
  providedIn: ServiceModule
})
export class LivelibService {

  constructor(private http: HttpClient, @Inject(API_CONFIG) private uri: string) { }

  page(selectData: any) {
    let url = this.uri + '/custom/livelib/page';
    return this.http.post(url, selectData);
  }

  playInfo(id: number) {
    let url = this.uri + '/custom/livelib/play-url/' + id.toString();
    return this.http.get(url);
  }

  save(data: any) {
    let url = this.uri + '/custom/livelib/save';
    return this.http.post(url, data);
  }

  delete(id: number) {
    let url = this.uri + '/custom/livelib/delete/' + id.toString();
    return this.http.delete(url);
  }

  disconnect(id: number) {
    let url = this.uri + '/custom/livelib/disconnect/' + id.toString();
    return this.http.get(url);
  }

  getSecret(id: number) {
    let url = this.uri + '/custom/livelib/getSecret/' + id.toString();
    return this.http.get(url);
  }

  getOnlineLive() {
    let url = this.uri + '/custom/livelib/online';
    return this.http.get(url);
  }

  qrcode(id: string) {
    let url = this.uri + '/custom/livelib/qrcode/' + id.toString();
    return this.http.get(url);
  }

  watchPage(selectData: any) {
    let url = this.uri + '/custom/watch/page';
    return this.http.post(url, selectData);
  }

  messagePage(selectData: any) {
    let url = this.uri + '/custom/watch/page-message';
    return this.http.post(url, selectData);
  }

  refuse(id: number) {
    let url = this.uri + '/custom/watch/refuse-message/' + id.toString();
    return this.http.get(url);
  }

  deRefuse(id: number) {
    let url = this.uri + '/custom/watch/derefuse-message/' + id.toString();
    return this.http.get(url);
  }

  requestApi(params: any) {
    let url = this.uri + '/custom/livelib/post-api';
    return this.http.post(url, params);
  }


}
